<style>.footer.footer-home {display: none;}</style>
<div class="header">
    <a href='index.php?act=member' class="return iconfont icon-shangyiye"></a>
    <div class="header-title">我的信息</div>
</div>
<div style="height:4rem;" class="ddd"></div>
<div class="btn-div">
    <a href="javascript:add();" class="btn ">+ &nbsp;新增</a>
</div>
<div class="tour-list">
    <ul>
        <?php foreach ($output['infos'] as $info): ?>
        <li>
            <div class="tour-info">
                <p><?php echo $info['mb_name']; ?>&nbsp;&nbsp;&nbsp;<span><?php echo $info['mb_phone']; ?></span></p>
                <span>身份证：&nbsp;&nbsp;<?php echo $info['mb_idcard']; ?></span>
            </div>
            <div class="right-btn">
                <a href="javascript:add(<?php echo $info['id']; ?>);" class="iconfont icon-bi"></a>
                <a href="javascript:;" onclick="del(<?php echo $info['id']; ?>, $(this));" class="iconfont icon-lajitong"></a>
            </div>
        </li>
        <?php endforeach; ?>
    </ul>
</div>
<div id="add-content" style="display: none;position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color:#fff;">
    <div class="content content-bot">
        <form class="visitors" style="margin: auto;">
            <input type="hidden" name="id">
            <div class="visitors-list">
                <label>游客姓名</label>
                <input type="text" name="name" placeholder="请填写真实姓名" />
            </div>
            <div class="visitors-list">
                <label>手机号</label>
                <input type="text" name="phone" placeholder="用于接收确认短信" />
                <i class="iconfont "></i>
            </div>
            <div class="visitors-list">
                <label>身份证号</label>
                <input type="text" name="idcard" placeholder="请填写有效证件号码" />
                <i class="iconfont "></i>
            </div>
        </form>
    </div>
    <div class="btn-div">
        <a href="javascript:submitAdd();" class="btn" id="add-submit">保 存</a>
    </div>
</div>
<div id="info-content" style="display: none;position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color:#fff;"></div>

<script>
    var content = $('#info-content'),
        addform = $('#add-content'),
        type = '';

    function add(id) {
        if (id) {
            $.get('index.php?act=member&op=info_ajax&type=get&id=' + id, function (data) {
                if (data.errcode == 0) {
                    addform.find('input[name="id"]').val(data.errmsg.id);
                    addform.find('input[name="name"]').val(data.errmsg.mb_name);
                    addform.find('input[name="phone"]').val(data.errmsg.mb_phone);
                    addform.find('input[name="idcard"]').val(data.errmsg.mb_idcard);
                    addform.fadeIn();
                    type = 'edit';
                }
            }, 'json');

        } else {
            addform.fadeIn().find('input').val('');
            type = 'add';
        }
    }
    function submitAdd() {
        if (addform.find('input[name="name"]').val() == '') {
            popAlert('姓名不能为空');
        } else if (!(/^1\d{10}$/.test(addform.find('input[name="phone"]').val()))) {
            popAlert('手机号码不正确');
        } else {
            $.post('index.php?act=member&op=info_ajax&type=' + type, addform.find('form').serialize(), function (data) {
                if (data.errcode == 0) {
                    popAlert('保存成功', function () {
                        type = '';
                        location.reload();
                    });
                } else {
                    popAlert(data.errmsg);
                }
            }, 'json');
        }
    }
    function del(id, obj) {
        $.post('index.php?act=member&op=info_ajax&type=del', {id:id}, function (data) {
            if (data.errcode == 0) {
                obj.parent().parent().remove();
            } else {
                popAlert(data.errmsg);
            }
        }, 'json');
    }
</script>







